<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * Define the application's Commands schedule.
     *
     * @param \Illuminate\Console\Scheduling\Schedule $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        $schedule->command('cron:test')->everyMinute()
//            ->between('17:50', '19:00')
            ->withoutOverlapping(1500)
            ->onOneServer()
            ->onSuccess(function () {
                dd("Cron test success\n");
            })->onFailure(function () {
                dd("Cron test failure\n");
            })->appendOutputTo(storage_path('logs/cron_test.log'));
    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__ . '/Commands');

        require base_path('routes/console.php');
    }

    /**
     * 获取计划事件默认使用的时区
     *
     * @return \DateTimeZone|string|null
     */
    protected function scheduleTimezone()
    {
        return 'Asia/Shanghai';
    }
}
